package com.maweirdos.maicode.config;

import dev.langchain4j.community.store.memory.chat.redis.RedisChatMemoryStore;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author:  Maweirdos
 * Date:  2025/9/4 21:04
 * Description:  对话记忆存储配置类
 */
@Configuration
@ConfigurationProperties(prefix = "spring.data.redis")
@Data
public class RedisChatMemoryStoreConfig {
    /**
     * Redis服务器地址
     */
    private String host;

    /**
     * redis服务器端口
     */
    private int port;

    /**
     * redis服务器密码
     */
    private String password;

    /**
     * redis缓存过期时间
     */
    private long ttl;


    /**
     * 创建RedisChatMemoryStore对象
     * @return RedisChatMemoryStore对象
     */
    @Bean
    public RedisChatMemoryStore redisChatMemoryStore() {
        return RedisChatMemoryStore.builder()
                .host(host)
                .port(port)
                .password(password)
                .ttl(ttl)
                .build();
    }
}
